package tweeks.user.controller;

import java.io.IOException;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import tweeks.user.domain.User;
import tweeks.user.service.UserService;

@Controller
@RequestMapping(value="/user")
public class UserController {
	
	@Resource(name="UserNormalService")
	private UserService userService;
	
	@RequestMapping(method=RequestMethod.GET, value="/join")
	public String join(User user, ModelMap model) throws IOException {
		model.addAttribute("user", user);
		return "user/join";
	}
	
	@RequestMapping(method=RequestMethod.POST, value="/signin")
	public String signin(User user) throws IOException {
		userService.createUser(user);
		return "redirect:/login";
	}
	
	@RequestMapping(method=RequestMethod.GET, value="/mypage")
	public String myPage(User user) throws IOException {
		return "user/myPage";
	}
}
